package eventplanner.crawler;

import eventplanner.entities.Event;
import eventplanner.entities.Feed;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.util.ArrayList;
import java.util.List;

public class Main {

	private static final Logger LOG = LoggerFactory.getLogger(Main.class);

	public static void main(String[] args) throws ParserConfigurationException {
		String s = "aa83c197-5314-4c94-881e-ff4a2049d235";
		System.out.println(s.substring(2, s.length() - 2));


		RSSReader reader = new RSSReader();


		if (reader.login()) {
			List<Feed> feeds = new ArrayList<>();
			feeds.add(new Feed("Agenda FE", "https://intranet.sharepoint.hu.nl/FE/_layouts/listfeed.aspx?List={FC92FAFF-A136-4E14-9021-3133DA04AB4F}", false));
			feeds.add(new Feed("Agenda IGO", "https://intranet.sharepoint.hu.nl/FNT/_layouts/listfeed.aspx?List={99417FD0-CBD7-4BEC-A0BD-EBC75B78C93B}", false));
			feeds.add(new Feed("Agenda FG", "https://intranet.sharepoint.hu.nl/FG/_layouts/listfeed.aspx?List={07850AB1-A4B2-41EC-99A3-7A0AE114E9B3}", false));
			feeds.add(new Feed("Agenda FEM", "https://intranet.sharepoint.hu.nl/FEM/_layouts/listfeed.aspx?List={51CA6D00-3515-43C1-AA45-D61E67B1964E}", false));
			feeds.add(new Feed("Agenda FCJ", "https://intranet.sharepoint.hu.nl/FCJ/_layouts/listfeed.aspx?List={C6B10A4E-4859-4340-974F-93A77CBBCC15}", false));
			feeds.add(new Feed("Agenda FMR", "https://intranet.sharepoint.hu.nl/FMR/_layouts/listfeed.aspx?List={1A543457-0A78-43A0-A023-D907ECE4D5D2}", false));
			feeds.add(new Feed("Agenda FNT", "https://intranet.sharepoint.hu.nl/FNT/_layouts/listfeed.aspx?List={D31AF521-CA0C-4453-9C2C-5F4E8B5A8E46}", false));
			feeds.add(new Feed("Agenda ICT", "https://intranet.sharepoint.hu.nl/FNT/_layouts/listfeed.aspx?List={2A96E978-8C2F-4C42-986F-EE15E50C7D32}", false));
			feeds.add(new Feed("Agenda Facilitaire Dienst", "https://intranet.sharepoint.hu.nl/HUA/info/Facilitaire_dienst/_layouts/listfeed.aspx?List={193B347C-1AA5-4D74-B794-2B462848FB21}", false));
			feeds.add(new Feed("Agenda MHU", "https://intranet.sharepoint.hu.nl/HUD/info/MZ-HU/_layouts/listfeed.aspx?List={34094B87-3F20-45EB-9897-CBBB1EEF5995}", false));


			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

			for (Feed feed : feeds) {
				List<Event> events = reader.readFeed(builder, feed);

				LOG.info("Events found: {}", events.toString());
			}

		}
	}
}
